package com.hulk.boot.dubbo.health;

import org.springframework.boot.actuate.health.AbstractHealthIndicator;
import org.springframework.boot.actuate.health.Health.Builder;

import com.alibaba.dubbo.config.spring.ReferenceBean;
import com.alibaba.dubbo.rpc.service.EchoService;

/**
 * @author cmt
 *
 */
//@SuppressWarnings({ "rawtypes" })
public class DubboHealthIndicator extends AbstractHealthIndicator {
	

	private final ReferenceBean bean;
	
	public DubboHealthIndicator (ReferenceBean bean){
		this.bean = bean;
	}
	
	
    @Override
    protected void doHealthCheck(Builder builder) throws Exception {
    	builder.withDetail("interface", bean.getObjectType());
    	final EchoService service = (EchoService)bean.getObject();
    	service.$echo("hi");
        builder.up();
    }
}
